﻿using System;
using System.Windows.Forms;

namespace PlatformaNET_lab3
{
    public delegate void _delegate();
    public partial class ChildForm : Form
    {
        public static event _delegate _event;

        public int ParentId { get; private set; }
        public string Path { get; private set; }
        public new string _Name { get; private set; }
        public int Id { get; private set; }
        public bool exist { get; private set; }
        public TreeNode _TreeNode { get; set; }
        //public TreeNode _isCurrentNode { get; set; }

        public ChildForm(string name, int parentId, string path)//, TreeNode isCurrent)
        {
            //_isCurrentNode = isCurrent;
            ParentId = parentId;
            Path = path;

            InitializeComponent();
            Text = name;
            _Name = name;
            exist = true;
            fontDialog.ShowEffects = true;

            if (parentId == 0)
                czcionkaToolStripMenuItem.Visible = false;
            else
                czcionkaToolStripMenuItem.Visible = true;

        }

        public override sealed string Text
        {
            get { return base.Text; }
            set { base.Text = value; }
        }

        public ChildForm()
        {
            InitializeComponent();
        }

        private void ChildForm_FormClosed(object sender, FormClosedEventArgs e)
        {
            this.exist = false;
            //richTextBox.Text = "";
            if (_event != null)
                _event();
        }

        private void ChildForm_Enter(object sender, EventArgs e)
        {
            //if (_TreeNode != null)
            //{
            //   // _isCurrentNode = _TreeNode;
            //}
        }

        private void czcionkaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (fontDialog.ShowDialog() != DialogResult.Cancel)
            {
                this.richTextBox.SelectionFont = fontDialog.Font;
                Invalidate();
            }
        }
    }
}
